package com.jxw.launcher;

import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.support.v4.content.FileProvider;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.jht.engine.platsign.LoginService;
import com.jht.engine.platsign.PlatSignatureWrapper;
import com.jht.engine.platsign.SignUtil;
import com.jxw.adapter.GridViewAdapter;
import com.jxw.adapter.SubjectViewPagerAdapter;
import com.jxw.engine.platsign.MainActivity;
import com.jxw.launcher.AppInfo;
import com.jxw.launcher.TabAdapter;
import com.jxw.launcher.db.PreferenceHelper;
import com.jxw.launcher.model.CustomizeApp;
import com.jxw.launcher.particle.ItemOnClickListener;
import com.jxw.launcher.util.CheckFileAndDown;
import com.jxw.launcher.util.Factory;
import com.jxw.launcher.util.LauncherUtils;
import com.jxw.launcher.util.Logger;
import com.jxw.launcher.util.ReceiverUtil;
import com.jxw.launcher.util.Util;
import com.jxw.launcher.view.BatteryView;
import com.jxw.launcher.view.DragGridView;
import com.jxw.studyrecord.StudyRecordAPKInfo;
import com.jxw.utils.SHAUtil;
import com.jxw.utils.SystemPropertiesProxy;
import com.jxw.utils.ToastUtil;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.tencent.bugly.BuglyStrategy;
import com.tencent.bugly.beta.tinker.TinkerUtils;
import com.zzj.filedownloader.download.DownLoadListener;
import com.zzj.filedownloader.download.DownLoadManager;
import com.zzj.filedownloader.download.TaskInfo;
import com.zzj.filedownloader.download.dbcontrol.bean.SQLDownLoadInfo;
import com.zzj.ziputil.ArchiverManager;
import com.zzj.ziputil.IArchiverListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URL;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.List;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.TreeMap;
import java.util.regex.Pattern;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import net.lingala.zip4j.util.InternalZipConstants;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.cookie.ClientCookie;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import tv.danmaku.ijk.media.player.IjkMediaMeta;

/* loaded from: classes.dex */
public class ThemeActivity extends BaseThemeActivity implements View.OnFocusChangeListener {
    public static final String CUSTOM_PREFIX = "GKPT";
    private static final String LOG_DIR_PATH = Environment.getExternalStorageDirectory().toString() + "/check1.json";
    private static final int PAGE_AI = 2;
    private static final int PAGE_CT = 1;
    private static final int PAGE_MAIN = 0;
    private static final String TAG = "ThemeActivity";
    private static final String URL1 = "http://api3.jiumentongbu.com/api/jxwota/apk/check?apkIsbn=zndzgkptv5&@version=5.0";
    public static boolean isRegistered = false;
    public static boolean need_first_page = false;
    public static SharedPreferences pref;
    BackListener backListener;
    BannerIndicator bannerIndicator;
    private BatteryView battery_view;
    private RelativeLayout bt_title;
    boolean canRegist;
    public View customize;
    View done_app;
    private DownLoadManager downLoadManager;
    private String downProStrToast;
    DownloadCompleteReceiver downreceiver;
    DragGridView dragGridView;
    boolean editApp;
    View edit_app;
    private List<BaseFragment> fragments;
    private TextView grName;
    private TextView grade;
    private GridView gridView;
    GridViewAdapter gridViewAdapter;
    ImageView headImage;
    private Button hideBtn;
    private RelativeLayout home;
    String mMac;
    Notification mNotification;
    NotificationManager mNotificationManager;
    PlatSignatureWrapper mPlatformSignature;
    String mSeries;
    String mcpuid;
    private AlertDialog menuDialog;
    private List<CustomizeApp> myApps;
    MyFragmentAi myFragmentAi;
    MyFragmentAr myFragmentAr;
    MyFragmentJpk myFragmentJpk;
    MyFragmentSZTZ myFragmentSZTZ;
    MyFragmentSX myFragmentSx;
    MyFragmentXdf myFragmentXdf;
    MyFragmentYW myFragmentYw;
    MyFragmentZH myFragmentZH;
    MyFragmentXK myFragmentxk;
    MyFragmentYY myFragmentyy;
    LinearLayout periodLayout;
    TimerTask reportTask;
    RelativeLayout rl_yygx;
    String serial;
    private int size;
    List<TabBean> subjectList;
    RecyclerView subjectRecycler;
    NoScrollViewPager subjectViewPager;
    SubjectViewPagerAdapter subjectViewPagerAdapter;
    TabAdapter tabAdapter;
    IntentFilter timefilter;
    TextView tv_date;
    TextView tv_tab_title;
    TextView tv_time;
    TextView tv_update;
    private List<AppInfo> updateList;
    private volatile boolean isFirstShowDownLoading = true;
    private volatile boolean isFirstShow = true;
    private String[] applist = {"com.jxw.zhinengyuyin", "com.jxw.wuweijidanci", "com.iflytek.speechcloud", StudyRecordAPKInfo.PACKAGE_PHONETIC, StudyRecordAPKInfo.PACKAGE_CHARACTER, "com.jxw.jinfangyici", "com.jxw.singsound", "com.jxw.liancichengju", "com.jxw.examsystem", StudyRecordAPKInfo.PACKAGE_PIN_YIN, "com.jxw.jxwcalculator", StudyRecordAPKInfo.PACKAGE_KOU_JUE, "com.tech.translate", StudyRecordAPKInfo.PACKAGE_STUDY_DIAGNOSE, "com.jxw.yuwenxiezuo", "com.jxw.mskt.video", StudyRecordAPKInfo.PACKAGE_SECOND_LINE_EXAM, "com.jxw.schultegrid", "com.jxw.handwrite", "com.jxw.zncd", "com.jxw.special.video", "com.jxw.huiben", "com.zzj.calendar", "com.oirsdfg89.flg", StudyRecordAPKInfo.PACKAGE_STROKE_NAME, StudyRecordAPKInfo.PACKAGE_STROKE_RULE, StudyRecordAPKInfo.PACKAGE_PIAN_PANG, StudyRecordAPKInfo.PACKAGE_NUMBER, StudyRecordAPKInfo.PACKAGE_KOU_JUE, StudyRecordAPKInfo.PACKAGE_NAME_ON_LINE_STUDY, StudyRecordAPKInfo.PACKAGE_PERIODIC_TABLE, "com.iflytek.cyber.iot.show.core", "com.jxw.classtable", "com.jxw.rijiben", "com.esread.sunflowerstudent", "com.zwwl.learningmachine", "com.jxw.launcher", "com.iflytek.inputmethod", "cn.kuwo.kwmusiccar", "com.lightning.edu.ei", "com.quark.browser", "air.com.zhihuiyoujiao.flashplayer"};
    private BroadcastReceiver recer = new BroadcastReceiver() { // from class: com.jxw.launcher.ThemeActivity.1
        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            Log.e("zzj", "action =" + intent.getAction());
            if ("android.intent.action.PACKAGE_ADDED".equals(intent.getAction())) {
                String schemeSpecificPart = intent.getData().getSchemeSpecificPart();
                Log.d("zzj", "get======" + schemeSpecificPart);
                if (schemeSpecificPart.contains("jxw") && !schemeSpecificPart.equals("com.jxw.online_clickread")) {
                    return;
                }
                for (int i = 0; i < ThemeActivity.this.applist.length; i++) {
                    if (schemeSpecificPart.equals(ThemeActivity.this.applist[i])) {
                        return;
                    }
                }
                if (!ThemeActivity.this.getAppData2(schemeSpecificPart)) {
                    ThemeActivity.this.writeAppDate(schemeSpecificPart);
                }
                Log.i("sizeadd", ThemeActivity.this.size + "size");
            } else if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) {
                String schemeSpecificPart2 = intent.getData().getSchemeSpecificPart();
                Log.e(ThemeActivity.TAG, schemeSpecificPart2 + "卸载成功");
            }
            Log.e("zzj", ThemeActivity.this.size + "size");
        }
    };
    private Handler mHandler = new Handler();
    private BroadcastReceiver receiver = new AnonymousClass2();
    private BroadcastReceiver recer1 = new BroadcastReceiver() { // from class: com.jxw.launcher.ThemeActivity.3
        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            if ("android.intent.action.PACKAGE_ADDED".equals(intent.getAction())) {
                String schemeSpecificPart = intent.getData().getSchemeSpecificPart();
                Log.d("zzj", "getOtaData=" + schemeSpecificPart);
                ThemeActivity.this.getOtaData(schemeSpecificPart);
            }
        }
    };
    private List<String> paths = new ArrayList();
    private int position = 0;
    BroadcastReceiver broadcastReceiver2 = new BroadcastReceiver() { // from class: com.jxw.launcher.ThemeActivity.17
        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            ThemeActivity.this.headImage.setImageDrawable(new BitmapDrawable(BitmapFactory.decodeFile(intent.getExtras().getString("data"))));
        }
    };
    private BroadcastReceiver networkReceiver = new AnonymousClass21();
    boolean canReport = true;
    Timer t = new Timer();
    private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { // from class: com.jxw.launcher.ThemeActivity.28
        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            Logger.getLogger().e(intent.getAction());
            if ("android.intent.action.TIME_TICK".equals(intent.getAction())) {
                ThemeActivity.this.tv_time.setText(ThemeActivity.this.updateTime());
                ThemeActivity.this.tv_date.setText(ThemeActivity.this.updateDate());
            } else if ("android.intent.action.TIME_SET".equals(intent.getAction())) {
                ThemeActivity.this.tv_time.setText(ThemeActivity.this.updateTime());
                ThemeActivity.this.tv_date.setText(ThemeActivity.this.updateDate());
            }
        }
    };

    private void hidenOta() {
    }

    private void register() {
    }

    private void unregister() {
    }

    @Override // android.view.View.OnFocusChangeListener
    public void onFocusChange(View view, boolean z) {
    }

    static /* synthetic */ int access$908(ThemeActivity themeActivity) {
        int i = themeActivity.position;
        themeActivity.position = i + 1;
        return i;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void checkStatusRules(String str) {
        Log.e("zdm", "series:" + str);
        if (str == null || str.length() < 16) {
            if (isRegistered) {
                return;
            }
            showMyDialog(R.layout.dialog_offline_sn, str);
            return;
        }
        if (!CUSTOM_PREFIX.equals(str.substring(0, 4)) && !isRegistered) {
            Log.e("zdm", "11111");
            showMyDialog(R.layout.dialog_offline_sn, str);
            return;
        }
        String substring = str.substring(4, 16);
        String substring2 = substring.substring(0, 2);
        if (!isAcronym(substring2) && !isRegistered) {
            Log.e("zdm", "222222");
            showMyDialog(R.layout.dialog_offline_sn, str);
            return;
        }
        String substring3 = substring.substring(2, 3);
        int charAt = (substring.charAt(0) + substring.charAt(1)) % 10;
        if (isInteger(substring3)) {
            int parseInt = Integer.parseInt(substring3);
            Log.e("zdm", "Num:" + charAt + "\tnum2:" + parseInt);
            if (charAt != parseInt && !isRegistered) {
                Log.e("zdm", "333333");
                showMyDialog(R.layout.dialog_offline_sn, str);
                return;
            }
        } else if (!isRegistered) {
            Log.e("zdm", "444444");
            showMyDialog(R.layout.dialog_offline_sn, str);
            return;
        }
        String substring4 = substring.substring(3, 10);
        if (!isInteger(substring4) && !isRegistered) {
            Log.e("zdm", "55555");
            showMyDialog(R.layout.dialog_offline_sn, str);
            return;
        }
        String substring5 = substring.substring(10);
        if (!isInteger(substring5) && !isRegistered) {
            Log.e("zdm", "66666");
            showMyDialog(R.layout.dialog_offline_sn, str);
            return;
        }
        try {
            int parseInt2 = Integer.parseInt(substring5);
            String str2 = substring2 + charAt + substring4;
            int i = 52;
            for (int i2 = 0; i2 < str2.length(); i2++) {
                i += str2.charAt(i2);
            }
            int i3 = i % 100;
            Log.e("zdm", "verify:" + str2 + "\tverifyNum:" + parseInt2 + "\tc:" + i3);
            if (parseInt2 == i3 || isRegistered) {
                return;
            }
            Log.e("zdm", "77777");
            showMyDialog(R.layout.dialog_offline_sn, str);
        } catch (Exception unused) {
            if (isRegistered) {
                return;
            }
            Log.e("zdm", "8888");
            showMyDialog(R.layout.dialog_offline_sn, str);
        }
    }

    public static boolean isInteger(String str) {
        return Pattern.compile("^[-\\+]?[\\d]*$").matcher(str).matches();
    }

    public static boolean isAcronym(String str) {
        for (int i = 0; i < str.length(); i++) {
            if (Character.isLowerCase(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }

    private String readContent(String str, int i) {
        File fileStreamPath = getFileStreamPath("app_list_xx");
        if (!fileStreamPath.exists()) {
            return null;
        }
        try {
            BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
            String str2 = "";
            Logger.getLogger().e("pkg = " + str + "poi=" + i);
            int i2 = 0;
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    Logger.getLogger().e("line " + readLine);
                    if (!readLine.equals(str) || i != i2) {
                        str2 = str2 + readLine + "\n";
                    }
                    i2++;
                } else {
                    bufferedReader.close();
                    FileOutputStream fileOutputStream = new FileOutputStream(fileStreamPath, false);
                    Logger.getLogger().e("sb = " + str2);
                    fileOutputStream.write(str2.getBytes());
                    fileOutputStream.flush();
                    fileOutputStream.close();
                    return null;
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        } catch (IOException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void writeAppDate(String str) {
        if (getAppData(str)) {
            return;
        }
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(getFileStreamPath("app_list_xx"), true);
            fileOutputStream.write((str + "\n").getBytes());
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    private boolean getAppData(String str) {
        File fileStreamPath = getFileStreamPath("app_list_xx");
        if (!fileStreamPath.exists()) {
            return false;
        }
        try {
            BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
            PackageManager packageManager = getPackageManager();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    try {
                        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(readLine, 128);
                        new AppInfo.Builder().appLabel((String) packageManager.getApplicationLabel(applicationInfo)).pkgName(readLine).appIcon(packageManager.getApplicationIcon(applicationInfo)).build();
                    } catch (PackageManager.NameNotFoundException e) {
                        e.printStackTrace();
                    }
                } else {
                    bufferedReader.close();
                    return false;
                }
            }
        } catch (FileNotFoundException e2) {
            e2.printStackTrace();
            return false;
        } catch (IOException e3) {
            e3.printStackTrace();
            return false;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean getAppData2(String str) {
        File fileStreamPath = getFileStreamPath("app_list_xx");
        if (!fileStreamPath.exists()) {
            return false;
        }
        try {
            BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
            PackageManager packageManager = getPackageManager();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    try {
                        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(readLine, 128);
                        new AppInfo.Builder().appLabel((String) packageManager.getApplicationLabel(applicationInfo)).pkgName(readLine).appIcon(packageManager.getApplicationIcon(applicationInfo)).build();
                    } catch (PackageManager.NameNotFoundException e) {
                        e.printStackTrace();
                    }
                    if (str.equals(readLine)) {
                        return true;
                    }
                } else {
                    bufferedReader.close();
                    return false;
                }
            }
        } catch (FileNotFoundException e2) {
            e2.printStackTrace();
            return false;
        } catch (IOException e3) {
            e3.printStackTrace();
            return false;
        }
    }

    private void subjectData() {
        this.subjectList.clear();
        this.subjectViewPagerAdapter.notifyDataSetChanged();
        this.subjectList.add(new TabBean(R.drawable.tap_xdf, R.drawable.tap_xdfed, "学霸臻选"));
        this.subjectList.add(new TabBean(R.drawable.tap_aijzx, R.drawable.tap_aijzxed, "AI精准学"));
        this.subjectList.add(new TabBean(R.drawable.tap_ywjc, R.drawable.tap_ywjced, "语文基础"));
        this.subjectList.add(new TabBean(R.drawable.tap_sxjc, R.drawable.tap_sxjced, "数学基础"));
        this.subjectList.add(new TabBean(R.drawable.tap_yyjc, R.drawable.tap_yyjced, "英语基础"));
        this.subjectList.add(new TabBean(R.drawable.tap_xkjc, R.drawable.tap_xkjced, "学科基础"));
        this.subjectList.add(new TabBean(R.drawable.tap_sztz, R.drawable.tap_sztzed, "素质拓展"));
        this.subjectList.add(new TabBean(R.drawable.tap_jpk, R.drawable.tap_jpkv, "精品课"));
        this.subjectList.add(new TabBean(R.drawable.tap_zhy, R.drawable.tap_zhyed, "综合页"));
        this.fragments.clear();
        this.fragments.add(this.myFragmentXdf);
        this.fragments.add(this.myFragmentAi);
        this.fragments.add(this.myFragmentYw);
        this.fragments.add(this.myFragmentSx);
        this.fragments.add(this.myFragmentyy);
        this.fragments.add(this.myFragmentxk);
        this.fragments.add(this.myFragmentSZTZ);
        this.fragments.add(this.myFragmentJpk);
        this.fragments.add(this.myFragmentZH);
        this.subjectViewPagerAdapter.setFragments(this.fragments);
        this.tabAdapter.setData(this.subjectList);
        this.subjectViewPager.setCurrentItem(0);
        this.subjectViewPager.setOffscreenPageLimit(3);
        this.tabAdapter.setChoosePosition(0);
    }

    /* renamed from: com.jxw.launcher.ThemeActivity$2  reason: invalid class name */
    /* loaded from: classes.dex */
    class AnonymousClass2 extends BroadcastReceiver {
        AnonymousClass2() {
        }

        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if ("com.zzj.regist_success".equals(action)) {
                ThemeActivity themeActivity = ThemeActivity.this;
                themeActivity.startService(new Intent(themeActivity, LoginService.class));
                ThemeActivity.this.mPlatformSignature.start(new PlatSignatureWrapper.OnVerify() { // from class: com.jxw.launcher.ThemeActivity.2.1
                    @Override // com.jht.engine.platsign.PlatSignatureWrapper.OnVerify
                    public void onError(final boolean z) {
                        ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.2.1.1
                            @Override // java.lang.Runnable
                            public void run() {
                                if (z) {
                                    ThemeActivity.isRegistered = true;
                                    ThemeActivity.this.netReportTime();
                                    return;
                                }
                                ThemeActivity.isRegistered = false;
                            }
                        });
                    }
                });
            } else if ("com.zzj.ansystem.downed".equals(action)) {
                final String path = Environment.getExternalStorageDirectory().getPath();
                final String stringExtra = intent.getStringExtra(ClientCookie.PATH_ATTR);
                Log.d("zzj", "ansystem path=" + stringExtra);
                ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.2.2
                    @Override // java.lang.Runnable
                    public void run() {
                        if (!TextUtils.isEmpty(stringExtra)) {
                            ThemeActivity.this.archiver(stringExtra, path);
                            return;
                        }
                        ThemeActivity themeActivity2 = ThemeActivity.this;
                        themeActivity2.archiver(path + "/系统预置文件/ansystem.rar", path);
                    }
                });
            } else if ("com.zzj.download_resourcedownd".equals(action)) {
                MyApp.getInstance().mBottomBtnOnClickListener.onClick(context.getString(R.string.tag_args_resourcesdownload));
            } else if (action.equals("android.intent.action.SCREEN_ON")) {
                boolean inKeyguardRestrictedInputMode = ((KeyguardManager) context.getSystemService("keyguard")).inKeyguardRestrictedInputMode();
                Log.e("zzj", "屏幕亮屏了)..解锁=" + inKeyguardRestrictedInputMode);
                if (inKeyguardRestrictedInputMode) {
                    return;
                }
                ThemeActivity.this.mHandler.removeMessages(2);
                ThemeActivity.this.mHandler.sendEmptyMessageDelayed(2, context.getSharedPreferences("hymode", 0).getLong("one_time", 900000L));
            } else if (action.equals("android.intent.action.SCREEN_OFF")) {
                Log.i("zzj", "屏幕加锁广播(即灭屏了)...");
            } else if (action.equals("android.intent.action.USER_PRESENT")) {
                Log.i("zzj", "屏幕解锁广播...");
                ThemeActivity.this.mHandler.removeMessages(2);
                ThemeActivity.this.mHandler.sendEmptyMessageDelayed(2, context.getSharedPreferences("hymode", 0).getLong("one_time", 900000L));
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void getOtaData(String str) {
        synchronized (this.updateList) {
            for (AppInfo appInfo : this.updateList) {
                if (appInfo.packageName.equals(str)) {
                    this.updateList.remove(appInfo);
                    this.mHandler.sendEmptyMessage(0);
                    return;
                }
            }
        }
    }

    /* loaded from: classes.dex */
    private class DownloadManagerListener implements DownLoadListener {
        private DownloadManagerListener() {
        }

        @Override // com.zzj.filedownloader.download.DownLoadListener
        public void onStart(SQLDownLoadInfo sQLDownLoadInfo) {
            Logger logger = Logger.getLogger();
            logger.d("onStart,name=" + sQLDownLoadInfo.getTaskID());
        }

        @Override // com.zzj.filedownloader.download.DownLoadListener
        public void onProgress(SQLDownLoadInfo sQLDownLoadInfo, boolean z) {
            TaskInfo taskInfo = ThemeActivity.this.downLoadManager.getTaskInfo(sQLDownLoadInfo.getTaskID());
            if (taskInfo != null) {
                taskInfo.setDownFileSize(sQLDownLoadInfo.getDownloadSize());
                taskInfo.setFileSize(sQLDownLoadInfo.getFileSize());
                taskInfo.setOnDownloading(true);
            }
            if (ThemeActivity.this.position < ThemeActivity.this.size) {
                ThemeActivity themeActivity = ThemeActivity.this;
                StringBuilder sb = new StringBuilder();
                sb.append("正在下载，下载进度 ");
                double downloadSize = sQLDownLoadInfo.getDownloadSize();
                Double.isNaN(downloadSize);
                double fileSize = sQLDownLoadInfo.getFileSize();
                Double.isNaN(fileSize);
                sb.append((int) (((downloadSize * 1.0d) / fileSize) * 100.0d));
                sb.append("%(");
                sb.append(ThemeActivity.this.position + 1);
                sb.append(InternalZipConstants.ZIP_FILE_SEPARATOR);
                sb.append(ThemeActivity.this.size);
                sb.append(")");
                themeActivity.downProStrToast = sb.toString();
                Log.e("====tag===1=", sQLDownLoadInfo.getTaskID() + "==" + (ThemeActivity.this.position + 1) + InternalZipConstants.ZIP_FILE_SEPARATOR + ThemeActivity.this.size);
            } else {
                Log.e("====tag===2=", sQLDownLoadInfo.getTaskID() + "==" + (ThemeActivity.this.position + 1) + InternalZipConstants.ZIP_FILE_SEPARATOR + ThemeActivity.this.size);
            }
            Logger.getLogger().d("onProgress,name=" + sQLDownLoadInfo.getTaskID() + ",size=" + sQLDownLoadInfo.getDownloadSize());
        }

        @Override // com.zzj.filedownloader.download.DownLoadListener
        public void onStop(SQLDownLoadInfo sQLDownLoadInfo, boolean z) {
            Logger logger = Logger.getLogger();
            logger.d("onStop,name=" + sQLDownLoadInfo.getTaskID());
        }

        @Override // com.zzj.filedownloader.download.DownLoadListener
        public void onSuccess(SQLDownLoadInfo sQLDownLoadInfo) {
            ThemeActivity.access$908(ThemeActivity.this);
            if (ThemeActivity.this.position < ThemeActivity.this.size) {
                CheckFileAndDown.downFile(ThemeActivity.this.paths, ThemeActivity.this.position, ThemeActivity.this.downLoadManager);
            } else if (ThemeActivity.this.position == ThemeActivity.this.size) {
                CheckFileAndDown.isAllDownSus = true;
            }
        }

        @Override // com.zzj.filedownloader.download.DownLoadListener
        public void onError(SQLDownLoadInfo sQLDownLoadInfo) {
            Logger logger = Logger.getLogger();
            logger.d("onError,name=" + sQLDownLoadInfo.getTaskID());
            ThemeActivity.this.downLoadManager.deleteTask(sQLDownLoadInfo.getTaskID());
            ThemeActivity.access$908(ThemeActivity.this);
            if (ThemeActivity.this.position < ThemeActivity.this.size) {
                CheckFileAndDown.downFile(ThemeActivity.this.paths, ThemeActivity.this.position, ThemeActivity.this.downLoadManager);
            } else if (ThemeActivity.this.position == ThemeActivity.this.size) {
                CheckFileAndDown.isAllDownSus = true;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.jxw.launcher.BaseThemeActivity, com.jxw.launcher.BaseActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.SupportActivity, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_home);
        Factory.lastResume = 1;
        showAvtar();
        this.backListener = new BackListener(getApplicationContext());
        SharedPreferences sharedPreferences = getSharedPreferences(MainActivity.PREFERENCE, 0);
        sharedPreferences.edit();
        String string = sharedPreferences.getString(MainActivity.CUSTOMISBN, "");
        if (!TextUtils.isEmpty(string)) {
            "zndzgkptv5".equals(string);
        }
        this.bannerIndicator = (BannerIndicator) findViewById(R.id.banner_indicator);
        this.bannerIndicator.setCellCount(9);
        this.bannerIndicator.setCurrentPosition(0);
        this.battery_view = (BatteryView) findViewById(R.id.battery_view);
        this.tv_tab_title = (TextView) findViewById(R.id.tv_tab_title);
        this.tv_time = (TextView) findViewById(R.id.tv_time);
        this.tv_date = (TextView) findViewById(R.id.tv_date);
        this.customize = findViewById(R.id.custimze_app);
        this.edit_app = findViewById(R.id.edit_app);
        this.done_app = findViewById(R.id.done_app);
        this.gridView = (GridView) findViewById(R.id.all_app);
        this.dragGridView = (DragGridView) findViewById(R.id.my_app);
        this.myApps = new ArrayList();
        this.gridViewAdapter = new GridViewAdapter(this, this.myApps);
        this.editApp = false;
        this.dragGridView.setAdapter((ListAdapter) this.gridViewAdapter);
        this.dragGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { // from class: com.jxw.launcher.ThemeActivity.4
            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                if (ThemeActivity.this.editApp) {
                    if (ThemeActivity.this.myApps.size() != 1) {
                        ThemeActivity.this.myApps.remove(i);
                        ThemeActivity.this.gridViewAdapter.setData(ThemeActivity.this.myApps);
                        ThemeActivity.this.gridViewAdapter.notifyDataSetChanged();
                        return;
                    }
                    Toast.makeText(ThemeActivity.this, "至少要添加一个应用哦", 0).show();
                    return;
                }
                MyApp.getInstance().mBottomBtnOnClickListener.setContext(ThemeActivity.this);
                MyApp.getInstance().mBottomBtnOnClickListener.onClick(ThemeActivity.this.getString(((CustomizeApp) ThemeActivity.this.myApps.get(i)).tagRes));
            }
        });
        final BaseAdapter baseAdapter = new BaseAdapter() { // from class: com.jxw.launcher.ThemeActivity.5
            @Override // android.widget.Adapter
            public long getItemId(int i) {
                return i;
            }

            @Override // android.widget.Adapter
            public int getCount() {
                return Factory.allApps.size();
            }

            @Override // android.widget.Adapter
            public Object getItem(int i) {
                return Factory.allApps.get(i);
            }

            @Override // android.widget.Adapter
            public View getView(int i, View view, ViewGroup viewGroup) {
                ViewHolder viewHolder;
                if (view == null) {
                    view = LayoutInflater.from(ThemeActivity.this).inflate(R.layout.item_allapp, viewGroup, false);
                    viewHolder = new ViewHolder();
                    viewHolder.name_app = (TextView) view.findViewById(R.id.name_app);
                    viewHolder.add = (ImageView) view.findViewById(R.id.add);
                    viewHolder.icon_app = (ImageView) view.findViewById(R.id.icon_app);
                    view.setTag(viewHolder);
                } else {
                    viewHolder = (ViewHolder) view.getTag();
                }
                CustomizeApp customizeApp = Factory.allApps.get(i);
                viewHolder.name_app.setText(customizeApp.appName);
                viewHolder.icon_app.setBackgroundResource(customizeApp.resDraw);
                if (ThemeActivity.this.editApp) {
                    viewHolder.add.setVisibility(0);
                } else {
                    viewHolder.add.setVisibility(8);
                }
                return view;
            }

            /* renamed from: com.jxw.launcher.ThemeActivity$5$ViewHolder */
            /* loaded from: classes.dex */
            class ViewHolder {
                ImageView add;
                ImageView icon_app;
                TextView name_app;

                ViewHolder() {
                }
            }
        };
        this.edit_app.setOnClickListener(new View.OnClickListener() { // from class: com.jxw.launcher.ThemeActivity.6
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                ThemeActivity.this.done_app.setVisibility(0);
                ThemeActivity.this.edit_app.setVisibility(8);
                ThemeActivity.this.periodLayout.setVisibility(8);
                ThemeActivity.this.headImage.setVisibility(8);
                ThemeActivity themeActivity = ThemeActivity.this;
                themeActivity.editApp = true;
                themeActivity.gridViewAdapter.setEditApp(ThemeActivity.this.editApp);
                ThemeActivity.this.gridViewAdapter.notifyDataSetChanged();
                baseAdapter.notifyDataSetChanged();
            }
        });
        this.done_app.setOnClickListener(new View.OnClickListener() { // from class: com.jxw.launcher.ThemeActivity.7
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                ThemeActivity.this.done_app.setVisibility(8);
                ThemeActivity.this.headImage.setVisibility(8);
                ThemeActivity.this.periodLayout.setVisibility(8);
                ThemeActivity.this.edit_app.setVisibility(0);
                ThemeActivity themeActivity = ThemeActivity.this;
                themeActivity.editApp = false;
                themeActivity.gridViewAdapter.setEditApp(ThemeActivity.this.editApp);
                String str = "";
                for (int i = 0; i < ThemeActivity.this.gridViewAdapter.getCount() - 1; i++) {
                    str = str + ThemeActivity.this.gridViewAdapter.getItem(i).poi + ",";
                }
                if (ThemeActivity.this.gridViewAdapter.getCount() > 0) {
                    str = str + ThemeActivity.this.gridViewAdapter.getItem(ThemeActivity.this.gridViewAdapter.getCount() - 1).poi;
                }
                int currentItem = ThemeActivity.this.subjectViewPager.getCurrentItem();
                if (currentItem == 0) {
                    PreferenceHelper.write(ThemeActivity.this, "app", "page0", str);
                    Log.i("hfq", "hfq the test indexStrs1=" + str);
                } else {
                    PreferenceHelper.write(ThemeActivity.this, "app", "page1", str);
                    Log.i("hfq", "hfq the test indexStrs2=" + str);
                }
                ThemeActivity.this.gridViewAdapter.notifyDataSetChanged();
                baseAdapter.notifyDataSetChanged();
                Log.i("myA8pps", currentItem + "");
                for (CustomizeApp customizeApp : ThemeActivity.this.myApps) {
                    Log.i("refreshMyAppView", customizeApp.appName);
                }
                ThemeActivity.this.subjectViewPagerAdapter.getItem(currentItem).setGridData(ThemeActivity.this.myApps);
                if (currentItem == 4) {
                    ThemeActivity.this.subjectViewPagerAdapter.getItem(currentItem + 1).setGridData(ThemeActivity.this.myApps);
                    ThemeActivity.this.subjectViewPagerAdapter.getItem(currentItem + 2).setGridData(ThemeActivity.this.myApps);
                } else if (currentItem == 5) {
                    ThemeActivity.this.subjectViewPagerAdapter.getItem(currentItem - 1).setGridData(ThemeActivity.this.myApps);
                    ThemeActivity.this.subjectViewPagerAdapter.getItem(currentItem + 1).setGridData(ThemeActivity.this.myApps);
                } else if (currentItem == 6) {
                    ThemeActivity.this.subjectViewPagerAdapter.getItem(currentItem - 1).setGridData(ThemeActivity.this.myApps);
                    ThemeActivity.this.subjectViewPagerAdapter.getItem(currentItem - 2).setGridData(ThemeActivity.this.myApps);
                }
            }
        });
        findViewById(R.id.back_page).setOnClickListener(new View.OnClickListener() { // from class: com.jxw.launcher.ThemeActivity.8
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                ThemeActivity.this.home.setVisibility(0);
                ThemeActivity.this.subjectViewPager.setVisibility(0);
                ThemeActivity.this.headImage.setVisibility(0);
                ThemeActivity.this.periodLayout.setVisibility(0);
                ThemeActivity.this.customize.setVisibility(8);
                ThemeActivity themeActivity = ThemeActivity.this;
                themeActivity.editApp = false;
                themeActivity.done_app.setVisibility(8);
                ThemeActivity.this.edit_app.setVisibility(0);
                ThemeActivity.this.gridViewAdapter.setEditApp(ThemeActivity.this.editApp);
                ThemeActivity.this.gridViewAdapter.notifyDataSetChanged();
                baseAdapter.notifyDataSetChanged();
            }
        });
        this.gridView.setSelector(new ColorDrawable(0));
        this.gridView.setAdapter((ListAdapter) baseAdapter);
        this.gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { // from class: com.jxw.launcher.ThemeActivity.9
            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                if (ThemeActivity.this.editApp) {
                    CustomizeApp customizeApp = Factory.allApps.get(i);
                    if (ThemeActivity.this.myApps.contains(customizeApp)) {
                        ThemeActivity themeActivity = ThemeActivity.this;
                        Toast.makeText(themeActivity, "我的应用已存在" + customizeApp.appName, 0).show();
                        return;
                    }
                    int currentItem = ThemeActivity.this.subjectViewPager.getCurrentItem();
                    int size = ThemeActivity.this.myApps.size();
                    if (size == 3 && currentItem == 0) {
                        Toast.makeText(ThemeActivity.this, "最多只能添加3个应用哦", 0).show();
                        return;
                    } else if (size != 6) {
                        ThemeActivity.this.myApps.add(customizeApp);
                        ThemeActivity.this.gridViewAdapter.setData(ThemeActivity.this.myApps);
                        ThemeActivity.this.gridViewAdapter.notifyDataSetChanged();
                        return;
                    } else {
                        Toast.makeText(ThemeActivity.this, "最多只能添加6个应用哦", 0).show();
                        return;
                    }
                }
                MyApp.getInstance().mBottomBtnOnClickListener.setContext(ThemeActivity.this);
                MyApp.getInstance().mBottomBtnOnClickListener.onClick(ThemeActivity.this.getString(Factory.allApps.get(i).tagRes));
            }
        });
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        Common.Width = displayMetrics.widthPixels;
        Common.Height = displayMetrics.heightPixels;
        this.updateList = new ArrayList();
        try {
            Intent intent = new Intent();
            intent.setClassName("com.jxw.pushservice", "com.jxw.pushservice.JXWService");
            startService(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
        initViews();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(0);
        this.subjectRecycler.setLayoutManager(linearLayoutManager);
        this.tabAdapter = new TabAdapter(R.layout.item_tab, this.subjectList);
        this.subjectRecycler.setAdapter(this.tabAdapter);
        this.tabAdapter.setOnItemClickListener(new TabAdapter.RadiaoOnItemClickListener() { // from class: com.jxw.launcher.ThemeActivity.10
            @Override // com.jxw.launcher.TabAdapter.RadiaoOnItemClickListener
            public void onSelectClick(int i) {
                ThemeActivity.this.tabAdapter.setChoosePosition(i);
                ThemeActivity.this.subjectViewPager.setCurrentItem(i);
                ThemeActivity.this.bannerIndicator.setCurrentPosition(i);
            }
        });
        Log.i(TAG, "subjectDasta: 初始化fragment");
        this.myFragmentAr = new MyFragmentAr();
        this.myFragmentXdf = new MyFragmentXdf();
        this.myFragmentAi = new MyFragmentAi();
        this.myFragmentYw = new MyFragmentYW();
        this.myFragmentSx = new MyFragmentSX();
        this.myFragmentyy = new MyFragmentYY();
        this.myFragmentxk = new MyFragmentXK();
        this.myFragmentSZTZ = new MyFragmentSZTZ();
        this.myFragmentJpk = new MyFragmentJpk();
        this.myFragmentZH = new MyFragmentZH();
        this.subjectViewPagerAdapter = new SubjectViewPagerAdapter(getSupportFragmentManager(), this.fragments);
        this.subjectViewPager.setAdapter(this.subjectViewPagerAdapter);
        this.subjectViewPager.setCurrentItem(1);
        subjectData();
        this.subjectViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { // from class: com.jxw.launcher.ThemeActivity.11
            @Override // android.support.v4.view.ViewPager.OnPageChangeListener
            public void onPageScrolled(int i, float f, int i2) {
                com.jxw.utils.Logger logger = com.jxw.utils.Logger.getLogger();
                logger.e("onPageScrolled--" + i);
            }

            @Override // android.support.v4.view.ViewPager.OnPageChangeListener
            public void onPageSelected(int i) {
                com.jxw.utils.Logger logger = com.jxw.utils.Logger.getLogger();
                logger.e("onPageSelected--" + i);
                ThemeActivity.this.tabAdapter.setChoosePosition(i);
                ThemeActivity.this.tv_tab_title.setText(ThemeActivity.this.subjectList.get(i).getTab_Title());
                ThemeActivity.this.bannerIndicator.setCurrentPosition(i);
            }

            @Override // android.support.v4.view.ViewPager.OnPageChangeListener
            public void onPageScrollStateChanged(int i) {
                com.jxw.utils.Logger logger = com.jxw.utils.Logger.getLogger();
                logger.e("onPageScrollStateChanged--" + i);
            }
        });
        registReceiver();
        this.downreceiver = new DownloadCompleteReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.DOWNLOAD_COMPLETE");
        registerReceiver(this.downreceiver, intentFilter);
        registerReceiver(this.networkReceiver, new IntentFilter(ReceiverUtil.ACTION_CONNECTIVITY_ACTION));
        IntentFilter intentFilter2 = new IntentFilter();
        intentFilter2.addAction("android.intent.action.PACKAGE_ADDED");
        intentFilter2.addAction("android.intent.action.PACKAGE_REMOVED");
        intentFilter2.addDataScheme("package");
        registerReceiver(this.recer, intentFilter2);
        register();
        this.timefilter = new IntentFilter();
        this.timefilter.addAction("android.intent.action.TIME_TICK");
        this.timefilter.addAction("android.intent.action.TIME_SET");
        registerReceiver(this.broadcastReceiver, this.timefilter);
        this.tv_time.setText(updateTime());
        this.tv_date.setText(updateDate());
        if (Build.VERSION.SDK_INT >= 23 && checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
            requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
        }
        this.downLoadManager = new DownLoadManager(MyApp.getInstance());
        this.downLoadManager.setAllTaskListener(new DownloadManagerListener());
        boolean z = CheckFileAndDown.isAllDownSus;
        MyApp.getInstance().mBottomBtnOnClickListener.setListener(new AnonymousClass12());
        CheckFileAndDown.readCheckFile(getBaseContext());
    }

    /* renamed from: com.jxw.launcher.ThemeActivity$12  reason: invalid class name */
    /* loaded from: classes.dex */
    class AnonymousClass12 implements ItemOnClickListener.onDownProssListener {
        AnonymousClass12() {
        }

        @Override // com.jxw.launcher.particle.ItemOnClickListener.onDownProssListener
        public void OnDowmListener() {
            if (TextUtils.isEmpty(ThemeActivity.this.downProStrToast)) {
                if (ThemeActivity.this.isFirstShow) {
                    ToastUtil.showTextToastDia(ThemeActivity.this.getApplicationContext(), "正在校验数据，请稍等！");
                    ThemeActivity.this.isFirstShow = false;
                    ThemeActivity.this.subjectRecycler.postDelayed(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.12.1
                        @Override // java.lang.Runnable
                        public void run() {
                            ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.12.1.1
                                @Override // java.lang.Runnable
                                public void run() {
                                    ThemeActivity.this.isFirstShow = true;
                                }
                            });
                        }
                    }, DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS);
                }
            } else if (ThemeActivity.this.isFirstShowDownLoading) {
                ToastUtil.showTextToastDia(ThemeActivity.this.getApplicationContext(), ThemeActivity.this.downProStrToast);
                ThemeActivity.this.isFirstShowDownLoading = false;
                ThemeActivity.this.subjectRecycler.postDelayed(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.12.2
                    @Override // java.lang.Runnable
                    public void run() {
                        ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.12.2.1
                            @Override // java.lang.Runnable
                            public void run() {
                                ThemeActivity.this.isFirstShowDownLoading = true;
                            }
                        });
                    }
                }, DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void checkStatus(final String str) {
        String str2 = System.currentTimeMillis() + "";
        String genrateKey = SignUtil.genrateKey();
        TreeMap treeMap = new TreeMap();
        treeMap.put(MainActivity.APKISBN, "zngbgkptv5");
        treeMap.put("series", str);
        treeMap.put("timestamp", str2);
        treeMap.put("nonce", genrateKey);
        treeMap.put("appsecret", "PZbKVKQUavLmswFznRnuACg9u2o8pmhL");
        String str3 = "http://api3.jiumentongbu.com/api/jxwuser/status?apkIsbn=zngbgkptv5&series=" + str + "&timestamp=" + str2 + "&nonce=" + genrateKey + "&signature=" + SignUtil.signature(treeMap);
        Log.d("zzj", "checkStatus url=" + str3);
        new OkHttpClient().newCall(new Request.Builder().url(str3).build()).enqueue(new Callback() { // from class: com.jxw.launcher.ThemeActivity.13
            @Override // okhttp3.Callback
            public void onFailure(Call call, IOException iOException) {
                Log.d("zzj", "checkStatus onFailure=" + iOException.getMessage());
            }

            @Override // okhttp3.Callback
            public void onResponse(Call call, Response response) throws IOException {
                Log.d("zzj", "checkStatus =" + response);
                if (response.isSuccessful()) {
                    String string = response.body().string();
                    Log.d("zzj", "checkStatus json =" + string);
                    try {
                        if (new JSONObject(string).optJSONObject("data") == null) {
                            ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.13.1
                                @Override // java.lang.Runnable
                                public void run() {
                                    ThemeActivity.this.showMyDialog(R.layout.dialog_sn, str);
                                }
                            });
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void showMyDialog(int i, String str) {
        AlertDialog alertDialog = this.menuDialog;
        if (alertDialog != null) {
            alertDialog.dismiss();
        }
        this.menuDialog = new AlertDialog.Builder(this, R.style.Theme_Transparent).create();
        View inflate = LayoutInflater.from(this).inflate(i, (ViewGroup) null);
        this.hideBtn = (Button) inflate.findViewById(R.id.hide_btn);
        this.hideBtn.setOnLongClickListener(new View.OnLongClickListener() { // from class: com.jxw.launcher.ThemeActivity.14
            @Override // android.view.View.OnLongClickListener
            public boolean onLongClick(View view) {
                ThemeActivity.this.menuDialog.cancel();
                ThemeActivity.this.menuDialog.dismiss();
                return true;
            }
        });
        ((TextView) inflate.findViewById(R.id.sninfo)).setText("Info:SN=" + str);
        this.menuDialog.setView(inflate);
        this.menuDialog.setCancelable(false);
        this.menuDialog.setCanceledOnTouchOutside(false);
        this.menuDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { // from class: com.jxw.launcher.ThemeActivity.15
            @Override // android.content.DialogInterface.OnKeyListener
            public boolean onKey(DialogInterface dialogInterface, int i2, KeyEvent keyEvent) {
                return i2 == 84;
            }
        });
        this.menuDialog.show();
    }

    private void registReceiver() {
        IntentFilter intentFilter = new IntentFilter("com.zzj.ansystem.downed");
        intentFilter.addAction("com.zzj.regist_success");
        intentFilter.addAction("com.zzj.download_resourcedownd");
        intentFilter.addAction("android.intent.action.SCREEN_ON");
        intentFilter.addAction("android.intent.action.SCREEN_OFF");
        intentFilter.addAction("android.intent.action.USER_PRESENT");
        registerReceiver(this.receiver, intentFilter);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void archiver(String str, String str2) {
        final ProgressDialog progressDialog = new ProgressDialog(this, 3);
        progressDialog.setMessage("解压中，请稍候...");
        progressDialog.setTitle("解压文件");
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setProgressStyle(1);
        ArchiverManager.getInstance().doUnArchiver(str, str2, "", new IArchiverListener() { // from class: com.jxw.launcher.ThemeActivity.16
            @Override // com.zzj.ziputil.IArchiverListener
            public void onStartArchiver() {
                ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.16.1
                    @Override // java.lang.Runnable
                    public void run() {
                        progressDialog.show();
                    }
                });
            }

            @Override // com.zzj.ziputil.IArchiverListener
            public void onProgressArchiver(final int i, final int i2) {
                ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.16.2
                    @Override // java.lang.Runnable
                    public void run() {
                        progressDialog.setMax(i2);
                        progressDialog.setProgress(i);
                    }
                });
            }

            @Override // com.zzj.ziputil.IArchiverListener
            public void onEndArchiver() {
                ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.16.3
                    @Override // java.lang.Runnable
                    public void run() {
                        progressDialog.dismiss();
                    }
                });
            }
        });
    }

    public void onCustomize(View view) {
        Log.i(TAG, "onCustomize: d");
        refreshMyAppView();
        this.home.setVisibility(8);
        this.subjectViewPager.setVisibility(8);
        this.customize.setVisibility(0);
    }

    private void refreshMyAppView() {
        String readString;
        if (this.subjectViewPager.getCurrentItem() == 0) {
            readString = PreferenceHelper.readString(this, "app", "page0", "3,4,5");
        } else {
            readString = PreferenceHelper.readString(this, "app", "page1", "0,1,2,3,4,5");
        }
        String[] split = readString.split(",");
        this.myApps.clear();
        for (String str : split) {
            try {
                this.myApps.add(Factory.allApps.get(Integer.parseInt(str)));
            } catch (Exception unused) {
            }
        }
        this.gridViewAdapter.setData(this.myApps);
        this.gridViewAdapter.notifyDataSetChanged();
    }

    private void showAvtar() {
        String str = getDiskCacheDir(this) + File.separator + "head.jpg";
        registerReceiver(this.broadcastReceiver2, new IntentFilter(GRZXActivity.action));
    }

    @Override // com.jxw.launcher.BaseThemeActivity, com.jxw.launcher.BaseActivity, android.support.v4.app.FragmentActivity, android.app.Activity
    public void onResume() {
        String readString;
        super.onResume();
        this.grName.setText(pref.getString("name", "游客"));
        this.grade.setText(pref.getString("grade", ""));
        showAvtar();
        this.grName.setSelected(true);
        int currentItem = this.subjectViewPager.getCurrentItem();
        if (currentItem == 0) {
            readString = PreferenceHelper.readString(this, "app", "page0", "3,4,5");
        } else {
            readString = PreferenceHelper.readString(this, "app", "page1", "0,1,2,3,4,5");
        }
        String[] split = readString.split(",");
        this.myApps.clear();
        for (String str : split) {
            try {
                this.myApps.add(Factory.allApps.get(Integer.parseInt(str)));
            } catch (Exception unused) {
            }
        }
        this.subjectViewPagerAdapter.getItem(currentItem).setGridData(this.myApps);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.jxw.launcher.BaseThemeActivity, android.support.v4.app.FragmentActivity, android.app.Activity
    public void onPause() {
        super.onPause();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.support.v4.app.FragmentActivity, android.app.Activity
    public void onStop() {
        super.onStop();
    }

    public static void saveLogToFile(String str) {
        try {
            FileWriter fileWriter = new FileWriter(LOG_DIR_PATH);
            fileWriter.write(str);
            fileWriter.flush();
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static JSONArray getAllFiles(JSONArray jSONArray, String str) {
        File[] listFiles;
        File file = new File(str);
        if (file.exists() && (listFiles = file.listFiles()) != null) {
            for (File file2 : listFiles) {
                if (file2.isFile()) {
                    String absolutePath = file2.getAbsolutePath();
                    try {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("md5", SHAUtil.getMD5Checksum(absolutePath));
                        jSONObject.put(ClientCookie.PATH_ATTR, absolutePath.replace(Environment.getExternalStorageDirectory().getAbsolutePath(), ""));
                        Log.e("zzj", "_fInfo=" + jSONObject.toString());
                        jSONArray.put(jSONObject);
                    } catch (Exception unused) {
                    }
                } else if (file2.isDirectory()) {
                    getAllFiles(jSONArray, file2.getAbsolutePath());
                } else {
                    getAllFiles(jSONArray, file2.getAbsolutePath());
                }
            }
            return jSONArray;
        }
        return null;
    }

    private void startTranslateAnimation() {
        TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, 0.0f, -800.0f);
        translateAnimation.setFillAfter(false);
        translateAnimation.setDuration(900L);
        translateAnimation.setAnimationListener(new Animation.AnimationListener() { // from class: com.jxw.launcher.ThemeActivity.18
            @Override // android.view.animation.Animation.AnimationListener
            public void onAnimationRepeat(Animation animation) {
            }

            @Override // android.view.animation.Animation.AnimationListener
            public void onAnimationStart(Animation animation) {
            }

            @Override // android.view.animation.Animation.AnimationListener
            public void onAnimationEnd(Animation animation) {
                Toast.makeText(ThemeActivity.this, "清理完成!", 0).show();
            }
        });
    }

    private void startClearnService() {
        try {
            Log.d("zzj", "startClearnService start");
            Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.jxw.lock", "com.jxw.lock.service.CleanService"));
            startService(intent);
            Log.d("zzj", "startClearnService over");
        } catch (Exception e) {
            e.printStackTrace();
            Log.d("zzj", "startClearnService error");
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.jxw.launcher.BaseThemeActivity, android.support.v4.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        unregisterReceiver(this.receiver);
        unregisterReceiver(this.networkReceiver);
        unregisterReceiver(this.recer);
        unregisterReceiver(this.downreceiver);
        unregisterReceiver(this.broadcastReceiver);
        unregister();
        TimerTask timerTask = this.reportTask;
        if (timerTask != null) {
            timerTask.cancel();
        }
        Log.i("homejian", "onDestroy: ");
        super.onDestroy();
    }

    private void setPreferedHome() {
        LauncherUtils.setDefaultLauncher(getPackageManager(), new ComponentName("com.jxw.launcher", "com.jxw.launcher.ThemeActivity"), true);
    }

    public String getDiskCacheDir(Context context) {
        if ("mounted".equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) {
            return context.getExternalCacheDir().getPath();
        }
        return context.getCacheDir().getPath();
    }

    private void startActivity1(String str, String str2) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(str, str2));
        try {
            intent.setFlags(276856832);
            startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void initViews() {
        this.home = (RelativeLayout) findViewById(R.id.home);
        this.subjectRecycler = (RecyclerView) findViewById(R.id.subject_recycle);
        this.subjectViewPager = (NoScrollViewPager) findViewById(R.id.subject_viewPager);
        this.grName = (TextView) findViewById(R.id.grname);
        this.grade = (TextView) findViewById(R.id.grade);
        pref = getSharedPreferences("userInfo", 0);
        this.subjectList = new ArrayList();
        this.fragments = new ArrayList();
        hidenOta();
        initInfoView();
        this.mPlatformSignature = new PlatSignatureWrapper(this);
        this.mPlatformSignature.start(new PlatSignatureWrapper.OnVerify() { // from class: com.jxw.launcher.ThemeActivity.19
            @Override // com.jht.engine.platsign.PlatSignatureWrapper.OnVerify
            public void onError(final boolean z) {
                ThemeActivity.this.runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.19.1
                    @Override // java.lang.Runnable
                    public void run() {
                        if (z) {
                            ThemeActivity.isRegistered = true;
                            ThemeActivity.this.netReportTime();
                            return;
                        }
                        ThemeActivity.isRegistered = false;
                        ThemeActivity.this.checkStatusRules(ThemeActivity.this.getDeviceSerial());
                    }
                });
            }
        });
        getSharedPreferences(MainActivity.PREFERENCE, 0).registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() { // from class: com.jxw.launcher.ThemeActivity.20
            @Override // android.content.SharedPreferences.OnSharedPreferenceChangeListener
            public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
                Log.e("zzj", "SharedPreferences=" + str);
                if (MainActivity.CERTIFICATION.equals(str)) {
                    ThemeActivity.this.mPlatformSignature.start(new PlatSignatureWrapper.OnVerify() { // from class: com.jxw.launcher.ThemeActivity.20.1
                        @Override // com.jht.engine.platsign.PlatSignatureWrapper.OnVerify
                        public void onError(final boolean z) {
                            ThemeActivity.this.mHandler.post(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.20.1.1
                                @Override // java.lang.Runnable
                                public void run() {
                                    Log.e("zzj", "success=" + z);
                                    if (z) {
                                        ThemeActivity.isRegistered = true;
                                    } else {
                                        ThemeActivity.isRegistered = false;
                                    }
                                }
                            });
                        }
                    });
                    if ("name".equals(str)) {
                        return;
                    }
                    "grade".equals(str);
                }
            }
        });
        checkWifiState();
    }

    public String updateTime() {
        String str;
        String str2;
        Calendar calendar = Calendar.getInstance();
        int i = calendar.get(11);
        int i2 = calendar.get(12);
        if (i >= 10) {
            str = "" + Integer.toString(i);
        } else {
            str = "0" + Integer.toString(i);
        }
        String str3 = str + ":";
        if (i2 >= 10) {
            str2 = str3 + Integer.toString(i2);
        } else {
            str2 = str3 + "0" + Integer.toString(i2);
        }
        return (calendar.get(11) >= 12 ? "下午" : "上午") + " " + str2;
    }

    public String updateDate() {
        String str;
        Calendar calendar = Calendar.getInstance();
        int i = calendar.get(11);
        int i2 = calendar.get(12);
        if (i >= 12) {
            i -= 12;
        }
        String str2 = "";
        if (i >= 10) {
            str = "" + Integer.toString(i);
        } else {
            str = "0" + Integer.toString(i);
        }
        String str3 = str + ":";
        if (i2 >= 10) {
            r0 = str3 + Integer.toString(i2);
        } else {
            String str4 = str3 + "0" + Integer.toString(i2);
        }
        String str5 = calendar.get(1) + "年";
        String str6 = (calendar.get(2) + 1) + "月";
        String str7 = calendar.get(5) + "日";
        switch (calendar.get(7)) {
            case 1:
                str2 = "星期日";
                break;
            case 2:
                str2 = "星期一";
                break;
            case 3:
                str2 = "星期二";
                break;
            case 4:
                str2 = "星期三";
                break;
            case 5:
                str2 = "星期四";
                break;
            case 6:
                str2 = "星期五";
                break;
            case 7:
                str2 = "星期六";
                break;
        }
        return str6 + str7 + " " + str2;
    }

    public void onClick(View view) {
        MyApp.getInstance().mBottomBtnOnClickListener.setContext(this);
        MyApp.getInstance().mBottomBtnOnClickListener.onClick((String) view.getTag());
    }

    /* renamed from: com.jxw.launcher.ThemeActivity$21  reason: invalid class name */
    /* loaded from: classes.dex */
    class AnonymousClass21 extends BroadcastReceiver {
        AnonymousClass21() {
        }

        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            ThemeActivity.this.checkWifiState();
            if (ReceiverUtil.ACTION_CONNECTIVITY_ACTION.equals(intent.getAction())) {
                NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
                if (activeNetworkInfo != null) {
                    Log.i("======", ThemeActivity.this.subjectList.size() + "");
                    if (activeNetworkInfo.isConnected()) {
                        Log.d("zzj", "networkReceiver=" + activeNetworkInfo.getType());
                        if (activeNetworkInfo.getType() == 1) {
                            ThemeActivity.this.mPlatformSignature.start(new PlatSignatureWrapper.OnVerify() { // from class: com.jxw.launcher.ThemeActivity.21.1
                                @Override // com.jht.engine.platsign.PlatSignatureWrapper.OnVerify
                                public void onError(boolean z) {
                                    if (!z) {
                                        ThemeActivity.this.checkStatus(ThemeActivity.this.getDeviceSerial());
                                    } else {
                                        new Thread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.21.1.1
                                            @Override // java.lang.Runnable
                                            public void run() {
                                                SharedPreferences sharedPreferences = ThemeActivity.this.getSharedPreferences(MainActivity.PREFERENCE, 0);
                                                String string = sharedPreferences.getString(MainActivity.CUSTOMISBN, null);
                                                String string2 = sharedPreferences.getString("registFlag", null);
                                                String string3 = sharedPreferences.getString("series", null);
                                                String string4 = sharedPreferences.getString(MainActivity.SERIS, null);
                                                ThemeActivity.this.register(Util.CHECK_REGIST_URL, sharedPreferences.getString("registMac", null), string, string2, string3, string4);
                                            }
                                        }).start();
                                    }
                                }
                            });
                            return;
                        } else if (activeNetworkInfo.getType() == 0) {
                            ThemeActivity.this.mPlatformSignature.start(new PlatSignatureWrapper.OnVerify() { // from class: com.jxw.launcher.ThemeActivity.21.2
                                @Override // com.jht.engine.platsign.PlatSignatureWrapper.OnVerify
                                public void onError(boolean z) {
                                    if (!z) {
                                        ThemeActivity.this.checkStatus(ThemeActivity.this.getDeviceSerial());
                                    } else {
                                        new Thread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.21.2.1
                                            @Override // java.lang.Runnable
                                            public void run() {
                                                SharedPreferences sharedPreferences = ThemeActivity.this.getSharedPreferences(MainActivity.PREFERENCE, 0);
                                                String string = sharedPreferences.getString(MainActivity.CUSTOMISBN, null);
                                                String string2 = sharedPreferences.getString("registFlag", null);
                                                String string3 = sharedPreferences.getString("series", null);
                                                String string4 = sharedPreferences.getString(MainActivity.SERIS, null);
                                                ThemeActivity.this.register(Util.CHECK_REGIST_URL, sharedPreferences.getString("registMac", null), string, string2, string3, string4);
                                            }
                                        }).start();
                                    }
                                }
                            });
                            return;
                        } else {
                            return;
                        }
                    }
                    return;
                }
                ThemeActivity themeActivity = ThemeActivity.this;
                themeActivity.checkStatusRules(themeActivity.getDeviceSerial());
            }
        }
    }

    @Override // com.jxw.launcher.BaseThemeActivity
    public String getDeviceSerial() {
        String str = SystemPropertiesProxy.get(this, "ro.serialno");
        if (TextUtils.isEmpty(str)) {
            if (Build.VERSION.SDK_INT >= 29) {
                str = Build.getSerial();
            } else {
                str = Build.SERIAL;
            }
        }
        return (TextUtils.isEmpty(str) || str.length() < 8) ? SystemPropertiesProxy.get(this, "persist.sys.serialno") : str;
    }

    public boolean isWifiConnect() {
        return ((ConnectivityManager) getSystemService("connectivity")).getNetworkInfo(1).isConnected();
    }

    public void checkWifiState() {
        if (isWifiConnect()) {
            int rssi = ((WifiManager) getApplicationContext().getSystemService("wifi")).getConnectionInfo().getRssi();
            if (rssi > -50 && rssi < 0) {
                Message message = new Message();
                message.what = 40;
                this.mHandler.sendMessage(message);
                return;
            } else if (rssi > -70 && rssi < -50) {
                Message message2 = new Message();
                message2.what = 39;
                this.mHandler.sendMessage(message2);
                return;
            } else if (rssi > -80 && rssi < -70) {
                Message message3 = new Message();
                message3.what = 38;
                this.mHandler.sendMessage(message3);
                return;
            } else if (rssi <= -100 || rssi >= -80) {
                return;
            } else {
                Message message4 = new Message();
                message4.what = 37;
                this.mHandler.sendMessage(message4);
                return;
            }
        }
        Message message5 = new Message();
        message5.what = 36;
        this.mHandler.sendMessage(message5);
    }

    @Override // android.app.Activity, android.view.KeyEvent.Callback
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            this.home.setVisibility(0);
            this.subjectViewPager.setVisibility(0);
            this.customize.setVisibility(8);
            this.editApp = false;
            this.done_app.setVisibility(8);
            this.edit_app.setVisibility(0);
            this.gridViewAdapter.setEditApp(this.editApp);
            this.gridViewAdapter.notifyDataSetChanged();
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    @Override // android.support.v4.app.FragmentActivity, android.app.Activity, android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        if (i != 1 || iArr.length <= 0) {
            return;
        }
        if (iArr[0] == 0) {
            return;
        }
        Toast.makeText(this, "权限拒绝部分功能无法正常使用", 0).show();
    }

    public void installApp(File file, Context context) {
        Intent intent = new Intent();
        intent.addFlags(C.ENCODING_PCM_MU_LAW);
        Logger logger = Logger.getLogger();
        logger.d("file=" + file.getAbsolutePath());
        intent.setAction("android.intent.action.VIEW");
        if (Build.VERSION.SDK_INT >= 24) {
            Uri uriForFile = FileProvider.getUriForFile(context, "com.jxw.launcher.fileprovider", file);
            intent.addFlags(1);
            intent.setDataAndType(uriForFile, "application/vnd.android.package-archive");
        } else {
            intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
        }
        try {
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public String register(String str, String str2, String str3, String str4, String str5, String str6) {
        Logger.getLogger().e("核实注册" + str2 + ",series=" + str5 + ",serial=" + str6 + ",apkV=" + str3);
        JSONObject jSONObject = new JSONObject();
        try {
            if (!TextUtils.isEmpty(str2)) {
                jSONObject.put("content", Base64.encodeToString(str2.getBytes("utf8"), 2));
            }
            jSONObject.put(MainActivity.APKISBN, str4);
            jSONObject.put("extraIsbn", str3);
            jSONObject.put("series", str5);
            jSONObject.put(IjkMediaMeta.IJKM_KEY_TYPE, "wifi");
            if (!TextUtils.isEmpty(str6)) {
                jSONObject.put("serial", str6);
            }
            String jSONObject2 = jSONObject.toString();
            byte[] genrateKey = genrateKey();
            byte[] encodeRSA = encodeRSA(genrateKey);
            byte[] bytes = jSONObject2.getBytes("utf8");
            encodeXor(bytes, genrateKey);
            String str7 = new String(Base64.encode(encodeRSA, 2), "utf8");
            String str8 = new String(Base64.encode(bytes, 2), "utf8");
            String str9 = str + "key=" + URLEncoder.encode(str7, "utf8") + "&sign=" + URLEncoder.encode(str8, "utf8");
            Logger.getLogger().e("核实注册 url===:" + str9);
            String remoteRequest = getRemoteRequest(str9);
            Logger.getLogger().e("核实注册 getRemoteRequest, result==:" + remoteRequest);
            if (remoteRequest != null) {
                JSONObject jSONObject3 = new JSONObject(remoteRequest);
                if (jSONObject3.optBoolean("success", false)) {
                    JSONObject optJSONObject = jSONObject3.optJSONObject("data");
                    boolean optBoolean = optJSONObject.optBoolean("registed", true);
                    boolean optBoolean2 = optJSONObject.optBoolean("disabled", false);
                    if (!optBoolean || optBoolean2) {
                        getSharedPreferences(MainActivity.PREFERENCE, 0).edit().clear().commit();
                        alarm(str2, str3, str4, str5, str6);
                    }
                }
            }
            return remoteRequest;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        } catch (UnknownHostException e2) {
            e2.printStackTrace();
            return null;
        } catch (JSONException e3) {
            e3.printStackTrace();
            return null;
        }
    }

    private String alarm(String str, String str2, String str3, String str4, String str5) {
        Logger.getLogger().e("mac=" + str + ",series=" + str4 + ",serial=" + str5 + ",apkV=" + str2);
        Log.e("zzj", "apkIsbn=" + str3 + "extraIsbn=" + str2 + "series=" + str4 + "type=wifiserial=" + str5);
        JSONObject jSONObject = new JSONObject();
        try {
            if (!TextUtils.isEmpty(str)) {
                jSONObject.put("content", Base64.encodeToString(str.getBytes("utf8"), 2));
            }
            jSONObject.put(MainActivity.APKISBN, str3);
            jSONObject.put("extraIsbn", str2);
            jSONObject.put("series", str4);
            jSONObject.put(IjkMediaMeta.IJKM_KEY_TYPE, "wifi");
            if (!TextUtils.isEmpty(str5)) {
                jSONObject.put("serial", str5);
            }
            String jSONObject2 = jSONObject.toString();
            byte[] genrateKey = genrateKey();
            byte[] encodeRSA = encodeRSA(genrateKey);
            byte[] bytes = jSONObject2.getBytes("utf8");
            encodeXor(bytes, genrateKey);
            String str6 = new String(Base64.encode(encodeRSA, 2), "utf8");
            String str7 = new String(Base64.encode(bytes, 2), "utf8");
            String str8 = Util.ALARM_URL + "key=" + URLEncoder.encode(str6, "utf8") + "&sign=" + URLEncoder.encode(str7, "utf8");
            Logger.getLogger().e("url=======================:" + str8);
            String remoteRequest = getRemoteRequest(str8);
            Logger.getLogger().e("getRemoteRequest, result=======================:" + remoteRequest);
            return remoteRequest;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        } catch (UnknownHostException e2) {
            e2.printStackTrace();
            return null;
        } catch (JSONException e3) {
            e3.printStackTrace();
            return null;
        }
    }

    private byte[] genrateKey() {
        Random random = new Random(SystemClock.elapsedRealtime());
        byte[] bArr = new byte[16];
        for (int i = 0; i < bArr.length; i++) {
            bArr[i] = (byte) random.nextInt(256);
        }
        return bArr;
    }

    private void encodeXor(byte[] bArr, byte[] bArr2) {
        int length = bArr2.length;
        for (int i = 0; i < bArr.length; i++) {
            bArr[i] = (byte) (bArr[i] ^ bArr2[i % length]);
        }
    }

    private byte[] encodeRSA(byte[] bArr) {
        try {
            Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding");
            cipher.init(1, KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decode("MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhAMRl646CuwCkA+kU3dvp5slwT7thqDGlKi6ar83bcMRzAgMBAAE=", 0))));
            return cipher.doFinal(bArr);
        } catch (InvalidKeyException e) {
            e.printStackTrace();
            return null;
        } catch (NoSuchAlgorithmException e2) {
            e2.printStackTrace();
            return null;
        } catch (InvalidKeySpecException e3) {
            e3.printStackTrace();
            return null;
        } catch (BadPaddingException e4) {
            e4.printStackTrace();
            return null;
        } catch (IllegalBlockSizeException e5) {
            e5.printStackTrace();
            return null;
        } catch (NoSuchPaddingException e6) {
            e6.printStackTrace();
            return null;
        }
    }

    private static String getRemoteRequest(String str) throws UnknownHostException {
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new DefaultHttpClient().execute(new HttpGet(str)).getEntity().getContent()));
            StringBuffer stringBuffer = new StringBuffer();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    stringBuffer.append(readLine);
                } else {
                    bufferedReader.close();
                    return stringBuffer.toString();
                }
            }
        } catch (UnknownHostException e) {
            throw e;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void reportData() {
        if (this.canReport) {
            this.canReport = false;
            final SharedPreferences sharedPreferences = getSharedPreferences(MainActivity.PREFERENCE, 0);
            String string = sharedPreferences.getString("registFlag", null);
            String string2 = sharedPreferences.getString("series", null);
            String string3 = sharedPreferences.getString("rToken", null);
            long currentTimeMillis = System.currentTimeMillis();
            String genrateKey = SignUtil.genrateKey();
            String str = Util.CHECK_SERIES_URL + "isbn=" + string + "&series=" + string2 + "&ts=" + currentTimeMillis + "&nonce=" + genrateKey;
            TreeMap treeMap = new TreeMap();
            treeMap.put("isbn", string);
            treeMap.put("series", string2);
            treeMap.put("ts", currentTimeMillis + "");
            if (!TextUtils.isEmpty(string3)) {
                str = str + "&token=" + string3;
                treeMap.put("token", string3);
            }
            treeMap.put("nonce", genrateKey);
            treeMap.put("appsecret", "MDwwDQYJKoZIhvcNAQEBBQADKwAw6CuwCkAkU3DGlKi6ar83bcMRzAgMBAAE");
            String str2 = str + "&signature=" + SignUtil.signature(treeMap);
            Logger.getLogger().d("url =" + str2);
            new OkHttpClient().newCall(new Request.Builder().url(str2).build()).enqueue(new Callback() { // from class: com.jxw.launcher.ThemeActivity.22
                @Override // okhttp3.Callback
                public void onFailure(Call call, IOException iOException) {
                    Logger logger = Logger.getLogger();
                    logger.d("login onFailure=" + iOException.getMessage());
                    ThemeActivity.this.canReport = true;
                }

                @Override // okhttp3.Callback
                public void onResponse(Call call, Response response) throws IOException {
                    Logger logger = Logger.getLogger();
                    logger.d("report =" + response);
                    if (response.isSuccessful()) {
                        try {
                            JSONObject jSONObject = new JSONObject(response.body().string());
                            Logger logger2 = Logger.getLogger();
                            logger2.d("json =" + jSONObject);
                            JSONObject jSONObject2 = jSONObject.getJSONObject("data");
                            boolean optBoolean = jSONObject2.optBoolean("registed", true);
                            boolean optBoolean2 = jSONObject2.optBoolean("disabled", false);
                            String optString = jSONObject2.optString("token");
                            if (optBoolean && !optBoolean2 && !TextUtils.isEmpty(optString)) {
                                if (!TextUtils.isEmpty(optString)) {
                                    sharedPreferences.edit().putString("rToken", optString).apply();
                                }
                            }
                            ThemeActivity.this.getSharedPreferences(MainActivity.PREFERENCE, 0).edit().clear().commit();
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    ThemeActivity.this.canReport = true;
                }
            });
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public String register(int i, String str, String str2, String str3, String str4, String str5) {
        Log.e("自动注册：", "flag=" + str5 + ",mac=" + str2 + ",serial=" + str3);
        if (i < 0 || str == null || str.isEmpty() || str2 == null || str2.isEmpty()) {
            return null;
        }
        String str6 = "";
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("http://pv.sohu.com/cityjson?ie=utf-8").openConnection();
            if (httpURLConnection.getResponseCode() == 200) {
                InputStream inputStream = httpURLConnection.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
                StringBuilder sb = new StringBuilder();
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    sb.append(readLine + "\n");
                }
                inputStream.close();
                String substring = sb.substring(sb.indexOf("{"), sb.indexOf("}") + 1);
                if (substring != null) {
                    try {
                        str6 = new JSONObject(substring).optString("cip");
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (MalformedURLException e2) {
            e2.printStackTrace();
        } catch (IOException e3) {
            e3.printStackTrace();
        }
        JSONObject jSONObject = new JSONObject();
        try {
            this.mMac = str2;
            String encodeToString = Base64.encodeToString(str2.getBytes("utf8"), 2);
            jSONObject.put(ClientCookie.VERSION_ATTR, i);
            jSONObject.put(TinkerUtils.PLATFORM, str);
            jSONObject.put("extraIsbn", "zndzgkptv5");
            jSONObject.put("IP", str6);
            jSONObject.put(MainActivity.APKISBN, "zngbgkptv5");
            jSONObject.put("IP", str6);
            jSONObject.put("series", str5);
            jSONObject.put(IjkMediaMeta.IJKM_KEY_TYPE, "wifi");
            jSONObject.put("content", encodeToString);
            if (!TextUtils.isEmpty(str3)) {
                jSONObject.put("serial", str3);
                this.mSeries = str3;
            } else if (!TextUtils.isEmpty(str4)) {
                jSONObject.put("serial", str4);
                this.mSeries = str4;
            }
            if (!TextUtils.isEmpty(str4)) {
                jSONObject.put("cpuid", str4);
                this.mSeries = str4;
            }
            String jSONObject2 = jSONObject.toString();
            byte[] genrateKey = genrateKey();
            byte[] encodeRSA = encodeRSA(genrateKey);
            byte[] bytes = jSONObject2.getBytes("utf8");
            encodeXor(bytes, genrateKey);
            String str7 = new String(Base64.encode(encodeRSA, 2), "utf8");
            String str8 = new String(Base64.encode(bytes, 2), "utf8");
            String str9 = Util.HOST + "/platform/platformsign.php?version=1&key=" + URLEncoder.encode(str7, "utf8") + "&sign=" + URLEncoder.encode(str8, "utf8") + "&vct=1.0";
            Log.e("自动注册", "url======:" + str9);
            String remoteRequest = getRemoteRequest(str9);
            Log.e("自动注册", "getRemoteRequest, result====:" + remoteRequest);
            return remoteRequest;
        } catch (UnsupportedEncodingException e4) {
            e4.printStackTrace();
            return null;
        } catch (UnknownHostException e5) {
            e5.printStackTrace();
            return null;
        } catch (JSONException e6) {
            e6.printStackTrace();
            return null;
        }
    }

    private void registDevice() {
        Log.e("zzj", "registDevice=:" + this.canRegist);
        if (this.canRegist) {
            this.canRegist = false;
            new Thread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.23
                @Override // java.lang.Runnable
                public void run() {
                    ThemeActivity themeActivity = ThemeActivity.this;
                    themeActivity.serial = themeActivity.getUserInfo();
                    ThemeActivity.this.mcpuid = ThemeActivity.getCPUSerial();
                    Log.e("zzj", "serial=:" + ThemeActivity.this.serial + ",cpuid=" + ThemeActivity.this.mcpuid);
                    String str = null;
                    if (ThemeActivity.this.mcpuid != null && ThemeActivity.this.mcpuid.contains("000000000000000")) {
                        ThemeActivity.this.mcpuid = null;
                    }
                    String serialNumber = ThemeActivity.this.getSerialNumber();
                    Log.e("zzj", "serial=:" + ThemeActivity.this.serial + ":flag " + serialNumber);
                    if (TextUtils.isEmpty(ThemeActivity.this.serial) && TextUtils.isEmpty(ThemeActivity.this.mcpuid) && TextUtils.isEmpty(serialNumber)) {
                        ThemeActivity.this.canRegist = true;
                        return;
                    }
                    for (int i = 0; i < 5; i++) {
                        try {
                            str = ThemeActivity.this.macAddress();
                        } catch (SocketException e) {
                            e.printStackTrace();
                        }
                        if (str != null) {
                            break;
                        }
                    }
                    String str2 = str;
                    Log.i(ThemeActivity.TAG, "mac dizhi : " + str2);
                    if (str2 != null) {
                        ThemeActivity themeActivity2 = ThemeActivity.this;
                        String[] parseResult = ThemeActivity.this.parseResult(themeActivity2.register(1, "A89S", str2, themeActivity2.serial, ThemeActivity.this.mcpuid, serialNumber));
                        if (parseResult != null) {
                            try {
                                int parseInt = Integer.parseInt(parseResult[0], 10);
                                if (parseInt >= 200 && parseInt <= 201 && ThemeActivity.this.saveCertification(parseResult[1])) {
                                    Log.i("自动注册", "自动注册成功");
                                    ThemeActivity.this.sendBroadcast(new Intent("com.zzj.regist_success"));
                                }
                            } catch (NumberFormatException e2) {
                                e2.printStackTrace();
                            }
                        } else {
                            Log.i("自动注册", "自动注册失败");
                        }
                    }
                    ThemeActivity.this.canRegist = true;
                }
            }).start();
        }
    }

    public String getUserInfo() {
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/sys/class/mmc_host/mmc0/mmc0:0001/cid"))));
            String readLine = bufferedReader.readLine();
            bufferedReader.close();
            return readLine;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x002c, code lost:
        r0 = r4.substring(r4.indexOf(":") + 1, r4.length()).trim();
     */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0061 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:19:0x004a -> B:37:0x005d). Please submit an issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static java.lang.String getCPUSerial() {
        /*
            r0 = 0
            java.io.File r1 = new java.io.File     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            java.lang.String r2 = "/proc/cpuinfo"
            r1.<init>(r2)     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            java.io.FileInputStream r2 = new java.io.FileInputStream     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            r2.<init>(r1)     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            java.io.LineNumberReader r1 = new java.io.LineNumberReader     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            java.io.InputStreamReader r3 = new java.io.InputStreamReader     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            r3.<init>(r2)     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            r1.<init>(r3)     // Catch: java.lang.Throwable -> L4e java.lang.Exception -> L53
            r2 = 1
            r3 = 1
        L19:
            r4 = 100
            if (r3 >= r4) goto L45
            java.lang.String r4 = r1.readLine()     // Catch: java.lang.Exception -> L43 java.lang.Throwable -> L5e
            if (r4 == 0) goto L45
            java.lang.String r5 = "Serial"
            int r5 = r4.indexOf(r5)     // Catch: java.lang.Exception -> L43 java.lang.Throwable -> L5e
            r6 = -1
            if (r5 <= r6) goto L40
            java.lang.String r3 = ":"
            int r3 = r4.indexOf(r3)     // Catch: java.lang.Exception -> L43 java.lang.Throwable -> L5e
            int r3 = r3 + r2
            int r2 = r4.length()     // Catch: java.lang.Exception -> L43 java.lang.Throwable -> L5e
            java.lang.String r2 = r4.substring(r3, r2)     // Catch: java.lang.Exception -> L43 java.lang.Throwable -> L5e
            java.lang.String r0 = r2.trim()     // Catch: java.lang.Exception -> L43 java.lang.Throwable -> L5e
            goto L45
        L40:
            int r3 = r3 + 1
            goto L19
        L43:
            r2 = move-exception
            goto L55
        L45:
            r1.close()     // Catch: java.io.IOException -> L49
            goto L5d
        L49:
            r1 = move-exception
            r1.printStackTrace()
            goto L5d
        L4e:
            r1 = move-exception
            r7 = r1
            r1 = r0
            r0 = r7
            goto L5f
        L53:
            r2 = move-exception
            r1 = r0
        L55:
            r2.printStackTrace()     // Catch: java.lang.Throwable -> L5e
            if (r1 == 0) goto L5d
            r1.close()     // Catch: java.io.IOException -> L49
        L5d:
            return r0
        L5e:
            r0 = move-exception
        L5f:
            if (r1 == 0) goto L69
            r1.close()     // Catch: java.io.IOException -> L65
            goto L69
        L65:
            r1 = move-exception
            r1.printStackTrace()
        L69:
            goto L6b
        L6a:
            throw r0
        L6b:
            goto L6a
        */
        throw new UnsupportedOperationException("Method not decompiled: com.jxw.launcher.ThemeActivity.getCPUSerial():java.lang.String");
    }

    public static String get(Context context, String str) throws IllegalArgumentException {
        try {
            Class<?> loadClass = context.getClassLoader().loadClass("android.os.SystemProperties");
            return (String) loadClass.getMethod("get", String.class).invoke(loadClass, new String(str));
        } catch (IllegalArgumentException e) {
            throw e;
        } catch (Exception unused) {
            return "";
        }
    }

    public String getSN() {
        return com.jxw.launcher.util.SystemPropertiesProxy.get(this, "ro.serialno");
    }

    public String getSerialNumber() {
        String str = com.jxw.launcher.util.SystemPropertiesProxy.get(this, "ro.serialno");
        if (str == null || str.equals("") || str.equals("unknown")) {
            if (Build.VERSION.SDK_INT >= 26) {
                String serial = Build.getSerial();
                return (serial == null || serial.equals("") || serial.equals("unknown")) ? Build.SERIAL : serial;
            }
            return Build.SERIAL;
        }
        return str;
    }

    public String macAddress() throws SocketException {
        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        String str = null;
        while (networkInterfaces.hasMoreElements()) {
            NetworkInterface nextElement = networkInterfaces.nextElement();
            byte[] hardwareAddress = nextElement.getHardwareAddress();
            if (hardwareAddress != null && hardwareAddress.length != 0) {
                StringBuilder sb = new StringBuilder();
                int length = hardwareAddress.length;
                for (int i = 0; i < length; i++) {
                    sb.append(String.format("%02x:", Byte.valueOf(hardwareAddress[i])));
                }
                if (sb.length() > 0) {
                    sb.deleteCharAt(sb.length() - 1);
                }
                String sb2 = sb.toString();
                Log.e("mac", "interfaceName=" + nextElement.getName() + ", mac=" + sb2);
                if (nextElement.getName().equals("wlan0")) {
                    Log.e("mac", " interfaceName =" + nextElement.getName() + ", mac=" + sb2);
                    str = sb2;
                }
            }
        }
        return str;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public String[] parseResult(String str) {
        String num;
        if (str == null || str == null || str.length() < 4) {
            return null;
        }
        String substring = str.substring(0, 4);
        if (substring.endsWith("-")) {
            num = substring.substring(0, 3);
        } else {
            num = Integer.toString(100);
        }
        return new String[]{num, str.substring(4)};
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean saveCertification(String str) {
        String[] split = str.split("-");
        SharedPreferences.Editor edit = getSharedPreferences(MainActivity.PREFERENCE, 0).edit();
        edit.putString(MainActivity.CERTIFICATION, split[0]);
        try {
            edit.putString(MainActivity.APKISBN, "A89S");
            edit.putString(MainActivity.CUSTOMISBN, "zndzgkptv5");
            edit.putString("registFlag", "zngbgkptv5");
            edit.putBoolean("isFirstIn", false);
            edit.putString(MainActivity.SERIS, this.mSeries);
            edit.putString("registMac", this.mMac + BuildConfig.MAIN_TYPE);
            if (split.length > 2) {
                edit.putString("series", split[2]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return edit.commit();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void netReportTime() {
        TimerTask timerTask = this.reportTask;
        if (timerTask != null) {
            timerTask.cancel();
        }
        this.reportTask = new TimerTask() { // from class: com.jxw.launcher.ThemeActivity.24
            @Override // java.util.TimerTask, java.lang.Runnable
            public void run() {
                ThemeActivity.this.reportData();
            }
        };
        this.t.schedule(this.reportTask, 20000L, 600000L);
    }

    /* loaded from: classes.dex */
    private class DownloadCompleteReceiver extends BroadcastReceiver {
        private DownloadCompleteReceiver() {
        }

        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            if (intent == null || !"android.intent.action.DOWNLOAD_COMPLETE".equals(intent.getAction())) {
                return;
            }
            long longExtra = intent.getLongExtra("extra_download_id", -1L);
            DownloadManager downloadManager = (DownloadManager) context.getSystemService("download");
            String mimeTypeForDownloadedFile = downloadManager.getMimeTypeForDownloadedFile(longExtra);
            if (TextUtils.isEmpty(mimeTypeForDownloadedFile)) {
                mimeTypeForDownloadedFile = "*/*";
            }
            Uri uriForDownloadedFile = downloadManager.getUriForDownloadedFile(longExtra);
            if (uriForDownloadedFile != null) {
                Intent intent2 = new Intent("android.intent.action.VIEW");
                intent2.setDataAndType(uriForDownloadedFile, mimeTypeForDownloadedFile);
                try {
                    context.startActivity(intent2);
                } catch (Exception unused) {
                }
            }
        }
    }

    public void connectDownLoad(final Context context, String str) {
        this.mNotificationManager = (NotificationManager) context.getSystemService("notification");
        HttpUtils httpUtils = new HttpUtils();
        httpUtils.configTimeout(BuglyStrategy.a.MAX_USERDATA_VALUE_LENGTH);
        httpUtils.configSoTimeout(BuglyStrategy.a.MAX_USERDATA_VALUE_LENGTH);
        httpUtils.download(str, Environment.getExternalStorageDirectory().getAbsolutePath() + "/realeas.apk", true, false, new RequestCallBack<File>() { // from class: com.jxw.launcher.ThemeActivity.25
            @Override // com.lidroid.xutils.http.callback.RequestCallBack
            public void onStart() {
                Logger.getLogger().e("onStart ");
                ThemeActivity themeActivity = ThemeActivity.this;
                themeActivity.setUpNotification(themeActivity.getPackageName(), context);
            }

            @Override // com.lidroid.xutils.http.callback.RequestCallBack
            public void onLoading(long j, long j2, boolean z) {
                Logger logger = Logger.getLogger();
                logger.e("onLoading " + j2);
                int i = (int) ((j2 * 100) / j);
                RemoteViews remoteViews = ThemeActivity.this.mNotification.contentView;
                remoteViews.setTextViewText(R.id.tv_progress, i + "%");
                remoteViews.setProgressBar(R.id.progressbar, 100, i, false);
                ThemeActivity.this.mNotificationManager.notify(1, ThemeActivity.this.mNotification);
            }

            @Override // com.lidroid.xutils.http.callback.RequestCallBack
            public void onSuccess(ResponseInfo<File> responseInfo) {
                ThemeActivity.this.mNotificationManager.cancel(1);
                Logger logger = Logger.getLogger();
                logger.e("onSuccess " + responseInfo);
                ThemeActivity.this.installApp(responseInfo.result, context);
            }

            @Override // com.lidroid.xutils.http.callback.RequestCallBack
            public void onFailure(HttpException httpException, String str2) {
                Logger logger = Logger.getLogger();
                logger.e("onFailure " + str2);
                RemoteViews remoteViews = ThemeActivity.this.mNotification.contentView;
                remoteViews.setTextViewText(R.id.tv_progress, "下载失败");
                remoteViews.setProgressBar(R.id.progressbar, 100, 0, false);
                ThemeActivity.this.mNotificationManager.notify(1, ThemeActivity.this.mNotification);
                File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/realeas.apk");
                if (file.exists()) {
                    ThemeActivity.this.installApp(file, context);
                }
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void setUpNotification(String str, Context context) {
        this.mNotification = new Notification(R.drawable.ic_launcher, "正在下载", System.currentTimeMillis());
        this.mNotification.flags = 2;
        RemoteViews remoteViews = new RemoteViews(str, (int) R.layout.download_notification_layout);
        Notification notification = this.mNotification;
        notification.contentView = remoteViews;
        this.mNotificationManager.notify(1, notification);
    }

    private static void toStudentApp(Context context, int i) {
        Context applicationContext = context.getApplicationContext();
        Intent intent = new Intent();
        intent.setPackage("com.viproom.smartclass.student");
        intent.setClassName("com.viproom.smartclass.student", "com.clovsoft.smartclass.tsone.MainActivity");
        intent.putExtra("page_id", i);
        intent.addFlags(335544320);
        try {
            applicationContext.startActivity(intent);
        } catch (Exception unused) {
        }
    }

    public void checkUpdate() {
        new OkHttpClient().newCall(new Request.Builder().url(URL1).build()).enqueue(new Callback() { // from class: com.jxw.launcher.ThemeActivity.26
            @Override // okhttp3.Callback
            public void onFailure(Call call, IOException iOException) {
                Log.d("zzj", "onFailure=" + iOException.getMessage());
            }

            @Override // okhttp3.Callback
            public void onResponse(Call call, Response response) throws IOException {
                ThemeActivity.this.getOtaData(response);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public synchronized void getOtaData(Response response) throws IOException {
        Log.d("zzj", "onResponse=" + response);
        if (response.isSuccessful()) {
            String string = response.body().string();
            PackageManager packageManager = MyApp.getInstance().getPackageManager();
            Log.d("zzj", "获取数据成功了:" + string);
            try {
                JSONArray jSONArray = new JSONObject(string).getJSONArray("data");
                final int i = 0;
                for (int i2 = 0; i2 < jSONArray.length(); i2++) {
                    JSONObject optJSONObject = jSONArray.optJSONObject(i2);
                    try {
                        if (optJSONObject.optInt("versionCode") > packageManager.getPackageInfo(optJSONObject.optString("packageName"), 0).versionCode) {
                            i++;
                            Log.e("num:", i + "");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                Log.e("finalnum:", i + "");
                runOnUiThread(new Runnable() { // from class: com.jxw.launcher.ThemeActivity.27
                    @Override // java.lang.Runnable
                    public void run() {
                        if (i > 0) {
                            TextView textView = ThemeActivity.this.tv_update;
                            textView.setText(i + "");
                            ThemeActivity.this.tv_update.setVisibility(0);
                            Log.e("2222222222222", "333333333");
                            ThemeActivity.this.rl_yygx.setVisibility(0);
                            return;
                        }
                        Log.e("jjjj", "333333333");
                    }
                });
            } catch (JSONException e2) {
                e2.printStackTrace();
            }
        }
    }
}
